<?php
class hchbase {
	
	public $isLogin;
	public function __construct() {
		$this->db = pc_base::load_model("mybasecontent_model");
        $this->dbType = pc_base::load_model("myassorttype_model");
		$this->dbLink = pc_base::load_model("mylink_model");
		
		$this->CURRENT_DATETIME = date('Y-m-d h:i:s',time());

		self::check_member();
		
		$whereSql = " is_show = 1";
		$orderSql = " show_index ASC,id DESC";
		$nav = $this->dbType->select($whereSql,'*','',$orderSql);
		
		$this->nav = array(
// 			'0'=>array('name'=>'首页','url'=>'/index.php?m=hchabout&c=index&a=init'),
			'1'=>array('name'=>'关于华创','url'=>'/index.php?m=hchabout&c=index&a=init'),
			'2'=>array('name'=>'创业故事','url'=>'/index.php?m=hchstory&c=index&a=init'),
			'3'=>array('name'=>'企业服务','url'=>'/index.php?m=hchservice&c=index&a=init'),
			'4'=>array('name'=>'浏览项目','url'=>'/index.php?m=hchbrowse&c=index&a=imageList'),
			'5'=>array('name'=>'人才对接','url'=>'/index.php?m=hchhr&c=index&a=init')
		);
		
		$whereSql = " name = 'roundimg'";
        $roundimgTypeId = $this->dbType->get_one($whereSql,'id');
        $whereSql = array('assort_type_id'=>$roundimgTypeId['id'],'is_del'=>0);
        $orderSql = " id DESC";
        $this->imgList = $this->db->select($whereSql,'*','',$orderSql);
        
        $whereSql = " is_del = 0";
        $this->linkList = $this->dbLink->select($whereSql,'*','',$orderSql);
	}
	
	/**
	 * 判断用户是否已经登陆
	 */
	final public function check_member() {
		$this->isLogin = false;
		$userid = param::get_cookie('_userid');
		$password = param::get_cookie('_password');
		if(!empty($userid)){
			$dbMember = pc_base::load_model('member_model');
			$this->memberinfo = $dbMember->get_one(array('userid'=>$userid));
			if($this->memberinfo && $this->memberinfo['password'] === $password) {
				$this->isLogin = true;
			}
		}
	}
	
	public function browse(){
		$id = $_GET['id'];
		$browse = $_GET['br'];
		$item['browse_times'] = $browse + 1;
		$this->db->update($item,$where = 'id = "'.$id.'"');
		
		
		echo $item['browse_times'];
	}

    //人才 获取职位类别
    function get_position($parent_no=0,$format='array'){
        if(!is_numeric($parent_no)) return array();
        $data = pc_base::load_model("myposition_model");
        $where = array();
        if(isset($parent_no)){
            $where['parent_no']=$parent_no;
        }
        $list = $data->select($where,'`id`,`position_no`,`position_name`,`parent_no`');
        if($format=='json'){
            return json_encode($list);
        }
        return $list;
    }

    //人才 获取行业类别
    function get_industry($parent_no=0,$format='array'){
        if(!is_numeric($parent_no)) return array();
        $data = pc_base::load_model("myindustry_model");
        $where = array();
        if(isset($parent_no)){
            $where['parent_no']=$parent_no;
        }
        $list = $data->select($where,'`id`,`industry_no`,`industry_name`,`parent_no`');
        if($format=='json'){
            return json_encode($list);
        }
        return $list;
    }

    //人才 获取地区
    function get_area($parent_no=0,$format='array'){
        if(!is_numeric($parent_no)) return array();
        $data = pc_base::load_model("myarea_model");
        $where = array();
        if(isset($parent_no)){
            $where['parent_no']=$parent_no;
        }
        $list = $data->select($where,'`id`,`area_no`,`area_name`,`parent_no`','',' `area_no` asc');
        if($format=='json'){
            return json_encode($list);
        }
        return $list;
    }

}
?>